﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NavManager.aspx.cs" Inherits="background.Manager.Config.Navigation.NavManager" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="../../Styles/index.css" rel="stylesheet" />
    <script src="../../Scripts/jquery-1.8.2.min.js"></script>
    <script src="../../Scripts/layer/layer.js"></script>

    <script type="text/javascript">
        function changeOrder(obj) {
            $.post("../Action/NavConfig.ashx", { action: "changeOrder", order: $(obj).val(), id: $(obj).attr("data-id") }, function (ret) {
                if (!ret) {
                    layer.msg("排序保存失败");
                }
            })
        }
        function deletes(_id) {
            if (confirm("确定要删除吗？")) {
                $.post("../Action/NavConfig.ashx", { action: "delete", id: _id }, function (ret) {
                    if (ret) {
                        layer.msg("删除成功，2秒后自动刷新页面", { icon: 1, time: 2000 }, function () { window.location.reload(); });
                    } else {
                        layer.msg("对不起删除失败，稍后再试", { icon: 2 });
                    }
                })
            }
        }
        function checkboxAll(obj) {
            $("input[name='idbox']").attr("checked", $(obj).is(":checked"));
        }
    </script>
</head>
<body>
    <div class="top">
        <strong>导航管理</strong>
        <span style="float: right"><a href="javascript:history.back();">
            <img src="../../Images/bak.png" />后退</a></span>
    </div>
    <div class="main">
        <div>
            <div class="tool_search">
            <% if(Request["type"].ToString()=="parent"){ %>
            <input type="button" class="sbtn" value="添加父分类" onclick="window.location.href = 'AddParentNav.aspx?actionType=add'" />
            <%}else{ %>
            <input type="button" class="sbtn" value="添加导航" onclick="window.location.href = 'AddNav.aspx?actionType=add&parent=<%=Request["parent"]%>'" /> &nbsp;<%=Codes.Navigation.getInfo("name", Request["parent"])["name"] %><%} %>
            </div>
            <table border="0" cellpadding="0" cellspacing="0" class="listtable">
                <tr>
                    <th class="th" style="width: 20px">
                        <input type="checkbox" onchange="checkboxAll(this)" /></th>
                    <th class="th">名称</th>
                    <th class="th">调用拼音</th>
                    <th class="th">链接地址</th>
                    <th class="th">分组</th>
                    <th class="th" style="width:40px">排序</th>
                    <th class="th thlast">操作</th>
                </tr>
                <%System.Data.DataTable dt= Codes.Navigation.getList(Request["type"].ToString()=="parent"?"-1":Request["parent"], ""); %>
                <%foreach(System.Data.DataRow dr in dt.Rows) {%>
                <tr>
                    <td class="td">
                        <input type="checkbox" name="idbox" value="<%=dr["id"] %>" /></td>
                    <td class="td"><%=dr["name"] %><%=Request["type"].ToString()=="parent"?"[<a style='color:#1f73b9;text-decoration: underline;' href='NavManager.aspx?type=son&parent="+dr["ID"]+"'>"+dr["scount"]+"</a>]":"" %>
                    <%=dr["state"].ToString()=="1"?"":"<sup style='color:#aaa'>(禁用)</sup>" %>
                    </td>
                    <td class="td"><%=dr["pyname"] %></td>
                    <td class="td"><%=dr["url"] %></td>
                    <td class="td"><%=dr["group"] %></td>
                    <td class="td" style="padding:0">
                        <input type="text" class="order" value="<%=dr["order"] %>" data-id="<%=dr["ID"] %>" onchange="changeOrder(this)" /></td>
                    <td class="td tdlast txtcenter">
                        <a href="<%=Request["type"].ToString()=="parent"?"AddParentNav":"AddNav" %>.aspx?actionType=update&id=<%=dr["id"] %>&parent=<%=dr["parent"] %>">
                            <img src="../../Images/edit.png" class="tool_edit" />编辑</a>
                        <a href="javascript:void(0);" onclick="deletes(<%=dr["id"] %>)">
                            <img src="../../Images/delete.png" class="tool_delete" />删除</a></td>
                </tr>
                <%} %>
            </table>
            <%--<div class="tcdPageCode"></div>
            <script src="../../Scripts/jquery.page.js"></script>
            <script>
                $(".tcdPageCode").createPage({
                    pageCount: '<%=Math.Ceiling((double)Codes.Links.getListCount()/10)%>',
                    current: '<%=string.IsNullOrEmpty(Request["p"])?"1":Request["p"]%>',
                    backFn: function (p) {
                        window.location.href = "?p=" + p;
                    }
                });
            </script>--%>
        </div>
    </div>
    <!--#include file='../../Include/footer.html'-->
</body>
</html>
